if (SERVER) then
	AddCSLuaFile("shared.lua");
	
	SWEP.Weight				= 5;
	SWEP.AutoSwitchTo		= false;
	SWEP.AutoSwitchFrom		= false;
end;

if (CLIENT) then
	SWEP.PrintName			= "Copper Hatchet";
	SWEP.Instructions		= "Primary fire: Chop wood from a tree.";
	SWEP.DrawAmmo			= false;
	SWEP.DrawCrosshair		= true;
	SWEP.ViewModelFOV		= 55;
	SWEP.ViewModelFlip		= false;
	SWEP.CSMuzzleFlashes	= false;
	SWEP.Slot 				= 3;
	SWEP.SlotPos			= 1;
end;

SWEP.Spawnable				= false;
SWEP.AdminSpawnable			= false;

SWEP.ViewModel				= Model("models/weapons/v_copper_hatchet.mdl");
SWEP.WorldModel				= Model("models/weapons/w_copper_hatchet.mdl");

SWEP.Primary.ClipSize		= -1;
SWEP.Primary.DefaultClip	= -1;
SWEP.Primary.Automatic		= true;
SWEP.Primary.Ammo			= "none";

SWEP.Secondary.ClipSize		= -1;
SWEP.Secondary.DefaultClip	= -1;
SWEP.Secondary.Automatic	= false;
SWEP.Secondary.Ammo			= "none";

function SWEP:Initialize()
	self:SetWeaponHoldType("melee2");
	self.sound = Sound("weapons/iceaxe/iceaxe_swing1.wav");
end

function SWEP:Reload()
end;

function SWEP:PrimaryAttack()
	self.Weapon:SetNextPrimaryFire(CurTime() +1);
    self.Weapon:SendWeaponAnim(ACT_VM_HITCENTER);
	self.Owner:SetAnimation(PLAYER_ATTACK1);

	if (SERVER) then
		self.Owner:EmitSound(self.sound);
		
		local tr = self.Owner:EyeTrace(100);
		
		if (IsValid(tr.Entity) and tr.Entity:IsTreeModel()) then
			local process = {
				Entity = tr.Entity,
				Chance = 60,
				MinAmount = 2,
				MaxAmount = 7,
				hitPosition = tr.HitPos
			};
			
			self.Owner:DoProcess("WoodCutting", 2, process);
		end;
	end;
end;

function SWEP:SecondaryAttack()
end;